﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service.BusinessLayer.Entities;
using Service.DataAccess.DataAccessHelper;
using System.Data.SqlClient;
using System.Data;

namespace Service.DataAccess.DataAccessLogic
{
    public class SoGiao_DA
    {
        public void them(SoGiao sg)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[4];
            par[0] = new SqlParameter("@masg",sg.Masg);
            par[1] = new SqlParameter("@manv", sg.Manv);
            par[2] = new SqlParameter("@makh", sg.Makh);
            par[3] = new SqlParameter("@ngaygiao", sg.Ngaygiao);
            help.InsertQuery("sp_sogiao_them",par);

        }
        public void sua(SoGiao sg)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[4];
            par[0] = new SqlParameter("@masg", sg.Masg);
            par[1] = new SqlParameter("@manv", sg.Manv);
            par[2] = new SqlParameter("@makh", sg.Makh);
            par[3] = new SqlParameter("@ngaygiao", sg.Ngaygiao);
            help.UpdateQuery("sp_sogiao_sua", par);
        }
        public void xoa(string masg)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@masg", masg);
            help.DeleteQuery("sp_sogiao_xoa", par);
        }
        public DataSet LayDS()
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            ds = help.SelectQuery("sp_sogiao_layds");
            return ds;
        }
        public DataSet LayDS_TheoNgayGiao(DateTime ngaygiao)
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@ngaygiao", ngaygiao);
            ds = help.SelectQuery("sp_sogiao_layds_ngaygiao", par);
            return ds;
        }
        public DataSet LayDS_NhanGiaoHang_Theo_KH(int MaKH,DateTime NgayGiao)
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            SqlParameter[] par = new SqlParameter[2];
            par[0] = new SqlParameter("@MaKH", MaKH);
            par[1] = new SqlParameter("@NgayGiao", NgayGiao);
            ds = help.SelectQuery("sp_DsNhanGiaoHang_Theo_KH", par);
            return ds;
        }
    }
}
